import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SPetArenaInfo } from "../../../../../Message/Game/SPetArenaInfo";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class PetCpnTopCellRenderer
    
    export  class PetCpnTopCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._petArenaInfo = arg1 as SPetArenaInfo;
            if (this._petArenaInfo) 
            {
                this._rankTxt.text = this._petArenaInfo.rank.toString();
                this._serverTxt.text = PlayerUtil.getProxyAndNameByEntityIdAndName(this._petArenaInfo.entityId, "");
                this._playerTxt.text = this._petArenaInfo.playerName;
            }
            return;
        }

        /* internal  */init(): void
        {
            this._rankTxt = ObjCreate.createTextField("", 13, 15, 200, 20, this);
            this._rankTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._serverTxt = ObjCreate.createTextField("", 40, 15, 115, 20, this, GlobalStyle.textFormatGreen);
            this._serverTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._playerTxt = ObjCreate.createTextField("", 127, 15, 115, 20, this, GlobalStyle.textFormatGreen);
            this._playerTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._viewBtn = ObjCreate.createGButton("", 235, 5, 59, 32, this, "PetCpnViewButton");
            this._viewBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onViewBtnClickHandler);
            this._viewBtn.drawNow();
            ObjCreate.createBg(0, 40, 290, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */onViewBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._petArenaInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetCpnView, this._petArenaInfo));
            }
            return;
        }

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_serverTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_viewBtn: GButton;

        /* internal */ /* var */_petArenaInfo: SPetArenaInfo;
    }
